/*    */ package com.bj58.analysis.tools.common;
/*    */ 
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.commons.lang.StringUtils;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class TrackUrlUtils
/*    */ {
/*    */   public static String formatTrackUrl(String trackUrl)
/*    */   {
/* 23 */     String tmpTrackUrl = null;
/* 24 */     if (StringUtils.isNotBlank(trackUrl)) {
/* 25 */       trackUrl = trackUrl.replace("%7B", "{").replace("%7D", "}").replace("%7b", "{").replace("%7d", "}").replace("%3A", ":").replace("%3a", ":").replace("\"", "'").replace("%2C", ",").replace("%2c", ",").replace(" ", "").replace("，", ",").replace("｛", "{").replace("｝", "}").replace("：", ":").replace("‘", "'").replace("’", "'").replace("%27", "'").replace("%20", "").replace("':'", "\001").replace("','", "\002").replace("':", "':'").replace(",'", "','").replace("\001", "':'").replace("\002", "','").replace(":'}", "''}").replace(",}", "}").replace("\\x", "%");
/*    */       
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 36 */       int indexPre = trackUrl.indexOf("{");
/* 37 */       if ((indexPre != 0) && (indexPre != -1)) {
/* 38 */         trackUrl = trackUrl.substring(indexPre, trackUrl.length());
/*    */       }
/* 40 */       int indexSuf = trackUrl.lastIndexOf("}");
/* 41 */       if (indexSuf == -1) {
/* 42 */         int tmpIndex = trackUrl.lastIndexOf("':'");
/* 43 */         String prefix = trackUrl.substring(0, tmpIndex + 3);
/* 44 */         String suffix = trackUrl.substring(tmpIndex + 3, trackUrl.length());
/* 45 */         suffix = suffix.replace("'", "").replace(",", "").replace("[", "");
/* 46 */         trackUrl = prefix + suffix + "'}";
/* 47 */       } else if (indexSuf != trackUrl.length() - 1) {
/* 48 */         trackUrl = trackUrl.substring(0, indexSuf + 1);
/*    */       }
/*    */       
/* 51 */       trackUrl = trackUrl.replace("':'", "\001").replace("','", "\002").replace("'", "").replace("{", "").replace("}", "").replace("\001", "':'").replace("\002", "','");
/*    */       
/*    */ 
/*    */ 
/* 55 */       int dIndex = trackUrl.lastIndexOf("','");
/* 56 */       int mIndex = trackUrl.lastIndexOf("':'");
/* 57 */       if (dIndex > mIndex)
/* 58 */         trackUrl = trackUrl.substring(0, dIndex);
/* 59 */       String[] trackUrls = trackUrl.split("','", -1);
/* 60 */       if ((trackUrls != null) && (trackUrl.length() != 0)) {
/* 61 */         Map<String, String> map = new HashMap();
/* 62 */         for (String tmp : trackUrls) {
/* 63 */           if (tmp.contains("':'")) {
/* 64 */             String[] tmps = tmp.split("':'", -1);
/* 65 */             String tmpKey = URLDecodeUtils.parser(tmps[0].replace("'", ""));
/* 66 */             String tmpValue = URLDecodeUtils.parser(tmps[1].replace("'", ""));
/* 67 */             map.put(tmpKey, tmpValue);
/*    */           }
/*    */         }
/*    */         
/* 71 */         if ((map != null) && (map.size() != 0)) {
/* 72 */           tmpTrackUrl = JSONObject.fromObject(map).toString();
/*    */         }
/*    */       }
/*    */     }
/*    */     
/* 77 */     return tmpTrackUrl;
/*    */   }
/*    */ }


/* Location:              C:\Users\zhaoxiang\Desktop\basestat_log_common_tools-0.3.jar!\com\bj58\analysis\tools\common\TrackUrlUtils.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */